﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Microsoft.Reporting.WebForms;


namespace iss.sg4210.se18.team6s.jass.Reports
{
    public partial class AdvertViewCount1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            AdvertViewCountDataSetTableAdapters.DistinctAdvertisersTableAdapter Ta =
                new AdvertViewCountDataSetTableAdapters.DistinctAdvertisersTableAdapter();

            AdvertViewCountDataSet.DistinctAdvertisersDataTable  dt = new AdvertViewCountDataSet.DistinctAdvertisersDataTable();

            Ta.Fill(dt);
            DropDownList1.DataSource = dt;
            DropDownList1.DataTextField = "UserName";
            DropDownList1.DataValueField = "UserName";
            DropDownList1.DataMember = "DistinctAdvertisers";
            DropDownList1.DataBind();

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            ReportViewer1.Visible = true;

            AdvertViewCountDataSetTableAdapters.AdvertViewCountTableAdapter Ta =
               new AdvertViewCountDataSetTableAdapters.AdvertViewCountTableAdapter();

            AdvertViewCountDataSet.AdvertViewCountDataTable dt = new AdvertViewCountDataSet.AdvertViewCountDataTable();
            Ta.Fill(dt, DropDownList1.SelectedValue);

            System.Data.DataTable TmpDataTable = dt;    

            ReportDataSource Rds = new ReportDataSource("AdvertViewCount", TmpDataTable);
            //ReportViewer1.Reset();
            ReportViewer1.LocalReport.DataSources.Clear();
            ReportViewer1.LocalReport.DataSources.Add(Rds);
            String tmpStr = Rds.ToString();

            ReportViewer1.LocalReport.Refresh();

        }


    }
}